#ifndef _TWITURI_H_
#define _TWITURI_H_
#include <twit/CommonMacros.h>

typedef enum ReturnFormat
{
	ReturnFormatJson	= 0x01,
	ReturnFormatXml		= 0x02,
	ReturnFormatRss		= 0x04,
	ReturnFormatAtom	= 0x08,
	ReturnFormatOauth	= 0x10
}ReturnFormat;

typedef enum SchemeType
{
	SchemeTypeHttp = 0,
	SchemeTypeHttps
}SchemeType;

#define def_twit_url		"api.twitter.com"
#define def_twit_version	1
#define def_twit_scheme		SchemeTypeHttp
#define def_twit_request	RequestMethodGet
#define def_twit_format		ReturnFormatJson

typedef void* TwitUri;


DLLEXPORT TwitUri TwitUri_create();
DLLEXPORT void TwitUri_destroy(TwitUri* p);

// set functions
DLLEXPORT void TwitUri_setSchemeType(TwitUri h, SchemeType type);
DLLEXPORT void TwitUri_setBaseUrl(TwitUri h, const char* url);
DLLEXPORT void TwitUri_setVersion(TwitUri h, const size_t version);
DLLEXPORT void TwitUri_setReturnFormat(TwitUri h,ReturnFormat format);
DLLEXPORT void TwitUri_setPath(TwitUri h, const char* path);
DLLEXPORT const char* TwitUri_getPath(TwitUri h);
DLLEXPORT void TwitUri_setFile(TwitUri h, const char* file);
DLLEXPORT const char* TwitUri_getFile(TwitUri h);
DLLEXPORT void TwitUri_setConstraints(TwitUri h, BOOL requiresAuth, BOOL rateLimited);

DLLEXPORT void TwitUri_setParamString(TwitUri h, const char* key, const char* val);
DLLEXPORT void TwitUri_setParamBoolean(TwitUri h, const char* key, BOOL val);
DLLEXPORT void TwitUri_setParamInt(TwitUri h, const char* key, int val);

// get functions
DLLEXPORT const char* TwitUri_get(TwitUri h);
DLLEXPORT ReturnFormat TwitUri_getReturnFormat(TwitUri h);

#ifdef __cplusplus
#include <string>
class CTwitUri
{
#define tu_(x) TwitUri_##x
	TwitUri h;
	std::string m_uri;
public:
	CTwitUri():h(NULL){	h = tu_(create)(); }
	~CTwitUri(){ tu_(destroy)(&h); }
	
	inline void setSchemeType(SchemeType type){ tu_(setSchemeType)(h,type); }
	inline void setBaseUrl(const char* url){ tu_(setBaseUrl)(h,url); }
	inline void setVersion(const size_t version){ tu_(setVersion)(h,version); }
	inline void setReturnFormat(ReturnFormat format){ tu_(setReturnFormat)(h,format); }
	inline void setPath(const char* path){ tu_(setPath)(h,path); }
	inline const char* getPath(){ return tu_(getPath)(h); }
	inline void setFile(const char* file){ tu_(setFile)(h,file); }
	inline const char* getFile(){ return tu_(getFile)(h); }
	inline void setConstraints(bool requiresAuth, bool rateLimited)
	{
		tu_(setConstraints)(h,requiresAuth?1:0, rateLimited?1:0);
	}
	inline void setParam(const char* key, const char* val=NULL)
	{
		tu_(setParamString)(h,key,val);
	}
	inline void setParam(const char* key, bool val)
	{
		tu_(setParamBoolean)(h,key,val?1:0);
	}
	inline void setParam(const char* key, int val)
	{
		tu_(setParamInt)(h,key,val);
	}

	inline std::string& getUri()
	{
		m_uri = tu_(get)(h);
		return m_uri;
	}
	inline const char* getUriCString(){ return tu_(get)(h); }
	inline ReturnFormat getReturnFormat(){ return tu_(getReturnFormat)(h);	}
};
#endif /*__cplusplus*/

#endif /*_TWITURI_H_*/

